<?php
/**
 * Created by PhpStorm.
 * User: worry
 * Date: 2017/12/21
 * Time: 22:14
 */

namespace common\components;


use Qiniu\Auth;
use Yii;

class Config
{
    private static $type;

    public static function getQiNiuConfig()
    {
        $qiniu = array(
            'AccessKey' => 'GCvXBsmNSq0zLV-L_9O8foIH3CHOc-SigTVWK6Z4',
            'SecretKey' => 'FR4ehHBBbjD7ZBNEvqIn2hKmqzTLMCK1TT-UX6-s',
            'bucket' => 'huishangpinshop',
            'domain' => 'http://img01.shanxinhui.com.cn/',
            'qiniu_url' => 'site',

//            'AccessKey'=>'nzLnJ7bLZV2NzisSuPh4Kut0AjiIffBwlg8OlrLB',
//            'SecretKey'=>'U9Mhfg39pyiozfDwhKf0D95ozARq9IJtlf-sb56u',
//            'bucket' =>'images',
//            'domain' =>'http://oqhlkwyzp.bkt.clouddn.com/',
//            'qiniu_url'=>'site',
        );
        $auth = new Auth($qiniu['AccessKey'], $qiniu['SecretKey']);
        $qiniu['token'] = $auth->uploadToken($qiniu['bucket']);
        return $qiniu;
    }

    public static function getConfig($name)
    {
        $type = Yii::$app->params['config_type'];
        self::$type = $type;
        return $type;
    }

    /**
     * @return mixed
     */
    public static function getType()
    {
        self::$type = Yii::$app->params['config_resource'] ? :'';
        return self::$type;
    }

    /**
     * @param mixed $type
     */
    public static function setType($type)
    {
        self::$type = $type;
    }
}